using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableMineSkillDao:DaoBase<TableMineSkill>
    {
        public override void AddPrimaryIndex(TableMineSkill model)
        {
            cachePrimary[model.MineItemID.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableMineSkill.txt";
        }

        protected override TableMineSkill ParseRowData(string[] rowData)
        {
            TableMineSkill data = new TableMineSkill();
			data.MineItemID = rowData [0];
			data.Name = rowData [1];
			data.Desc = rowData [2];
			data.Type = rowData [3];

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.Quality = 0;
            }
            else
            {
                data.Quality = int.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.Color = 0;
            }
            else
            {
                data.Color = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.Level = 0;
            }
            else
            {
                data.Level = int.Parse(rowData[6]);
            }
			data.Value = rowData [7];

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.LevelLimit = 0;
            }
            else
            {
                data.LevelLimit = int.Parse(rowData[8]);
            }
			data.SkillNeeded = rowData [9];

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.composeMeterial = 0;
            }
            else
            {
                data.composeMeterial = int.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.Compound = 0;
            }
            else
            {
                data.Compound = int.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.MakingExp = 0;
            }
            else
            {
                data.MakingExp = int.Parse(rowData[12]);
            }
			data.Product = rowData [13];
			data.ExtractGem = rowData [14];
			data.ExtractMagicStone = rowData [15];
			data.ExtractPowder = rowData [16];
			data.Material = rowData [17];

            return data;
        }


        public override void AddOneIndex(TableMineSkill model)
        {
            if (!cacheOneIndex.ContainsKey(model.Type.ToString()))
            {
                cacheOneIndex[model.Type.ToString()] = new List<TableMineSkill>();
            }
            cacheOneIndex[model.Type.ToString()].Add(model);
        }
    

    }

}
